#pragma once

#include "API/NiTypes/NiTList.h"

typedef void* NiTListIterator;

template <class T>
class NiTOrphanList : public NiTList<T*> {
public:
	bool	NthItem(UInt32 n, NiTListIterator k, T* p = NULL) const {
		if ( 0 <= n && n < GetSize() ) {
			p = NULL;
			k = GetHeadPos();
			for ( UInt32 i = 0; p && k && i <= n; ++i, p = GetNext(k) );
			if ( p && k ) {
				return true;
			}
		}
		return false;
	}
protected:
	virtual	void	DeleteItem(NiTListItem<T*>* pkItem) {
		delete pkItem->m_element;
		NiTList<T*>::DeleteItem(pkItem);
	}
};
